1. Field of the Invention
The present invention relates generally to an improved data processing system and in particular to a method and apparatus for processing data. Still more particularly, the present invention relates to a computer implemented method, apparatus, and computer usable program code for managing real memory to support dynamic promotion of page sizes in virtual memory.
2. Description of the Related Art
A computer system may address memory that is both real and virtual. In a real mode, a memory address register contains the address information that addresses a word or byte of the memory. The memory is addressed sequentially by adding to the address register. The location of the memory being addressed moves forward by the number being added to the address register. In a virtual mode, memory is divided into pages. Most operating systems use a page-virtual memory architecture in which virtual memory is mapped to real memory in units of fixed size pages.
To improve system performance, any computer architectures and operating systems now include support for multiple page sizes. Larger page sizes may significantly improve the performance of hardware translation mechanisms because these larger page sizes allow hardware translation caches to translate larger amounts of memory.
One problem of supporting multiple page sizes is how to efficiently manage real memory to support dynamic promotion of page size. An operating system needs to be able to dynamically remap a contiguous range of virtual memory pages as a single page of a larger page size to support dynamically changing the page size being used for an application. This remapping is also referred to as page promotion. This type of promotion of pages “promotes” smaller page size mappings into a single mapping of a larger page size.
In order to promote a contiguous group of smaller page size mappings into a single mapping for a larger page size, the virtual memory pages are required to be contiguous in real memory. For example, in order to remap the group of sixteen 4K pages as a single 64K page, all of the sixteen 4K pages must be contiguous in real memory. This requirement is needed so that a single 64K page translation can translate the entire virtual memory chunk of 64K.
Thus, in order to promote a group of smaller pages into a larger page, the operating system must make sure that the group of smaller pages is contiguous in real memory. One current mechanism used is to move pages around in the real memory before promoting the virtual pages. With this method, the operating system maps virtual pages into real memory whenever a free page frame is present. As a result, virtual pages are contiguous and the virtual address space is likely to be mapped to discontinuous locations in real memory.
When a dynamic promotion of the group of pages into a larger page is to occur, the operating system can rearrange the pages into a single contiguous range of real memory by moving the pages around in the real memory. This method provides significant flexibility with the initial allocation of pages in real memory. However, this method requires overhead in promoting pages because oftentimes pages have to be rearranged in real memory. If the operating system performs a large number of page promotions, a significant amount of processing may be required to move the pages around in real memory.
Another mechanism that is currently used is to initially map contiguous virtual pages into contiguous locations in real memory. This method involves preserving a contiguous region of memory or a contiguous range of virtual memory. Virtual memory pages are then mapped into the real memory range as pages are referenced.
For example, if an operating system supports page sizes of 4K and 64K, when a first 4K page for a given 64K virtual memory range is to be mapped into memory, the operating system reserves a 64K chunk of real memory. The 4K virtual page is mapped into an appropriate location in this chuck of memory reserved by the operating system. As other virtual memory pages in range are referenced, the operating system maps those pages into other locations in this 64K chuck of memory.
At a later time, when the operating system promotes the group of 4K pages into a 64K page, page movement migrations are not needed because the 4K virtual pages are already contiguous in the real memory. In this manner, this currently used method provides more efficient promotion of pages. This method, however, suffers from a potential waste of memory. Memory reservations made by the operating system to prepare for page promotion may never be used if the application does not trigger promotion threshold to cause the pages for the application to be promoted to a larger page size. This unused reserve memory is effectively wasted. Further, with very large page sizes, such as 256 megabyte pages, reserving memory in these large chunks requires a significant amount of overhead to create these large contiguous chunks of real memory.
Therefore, it would be advantageous to have an improved computer implemented method, apparatus, and computer usable program code for managing memory to support dynamic promotion of virtual memory pages.